package ch10_thread.thread;

/**
 * 在try catch中，中断线程失效
 *
 * @author guodd
 * @version 1.0 use jdk 1.8
 */
public class StopTryCatch {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            for (int i = 0; i < 100; i++) {
                System.out.println(i);
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
        });
        thread.start();
        Thread.sleep(5000);
        thread.interrupt();
    }
}
